﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AyaWo.DAL
{
    public class Logs 
    {
        /// <summary>
        /// 
        /// </summary>
        public string ID { get; set; }
        public DateTime CreateDate { get; set; }
        public string InfoType { get; set; }
        public string MessageInfo { get; set; }


    }
    public class Logser : BaseService
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msgInfo"></param>
        public static void Info(string msgInfo)
        {
            Logs logs = new Logs { InfoType = "信息", CreateDate = DateTime.Now, MessageInfo = msgInfo };
            string sqlstr = "INSERT into Logs(InfoType,CreateDate,MessageInfo) VALUES(@InfoType,@CreateDate,@MessageInfo)";
            Db.ExecuteBySql(new StringBuilder(sqlstr), logs);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msgInfo"></param>
        public static void Error(string msgInfo)
        {
            Logs logs = new Logs { InfoType = "错误信息", CreateDate = DateTime.Now, MessageInfo = msgInfo };
            string sqlstr = "INSERT into Logs(InfoType,CreateDate,MessageInfo) VALUES(@InfoType,@CreateDate,@MessageInfo)";
            Db.ExecuteBySql(new StringBuilder(sqlstr), logs);
        }

        /// <summary>
        /// 获取在还没有被关键字搜过过的  且 关键字有设置过的数据列表  
        /// </summary>
        /// <returns></returns>
        public static DataTable GetList()
        {
            string sqlStr = "select * from Logs ORDER BY CreateDate desc";
            return Db.GetDataTableBySqL (new StringBuilder(sqlStr));
        }
        public static DataTable GetSqliteList()
        {
            string sqlStr = "select t.ID 编码,t.CreateDate 创建时间,t.InfoType 日志类别,t.MessageInfo 错误信息 from Logs t ORDER BY CreateDate desc";
            return Db.GetDataTableBySqL(new StringBuilder(sqlStr));
        }
    }
}
